﻿using MeterialManager.Aop;
using MeterialManager.Aop.ServiceProcess;
using MeterialManager.Common;
using MeterialManager.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MeterialManager
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            //Test();
            //IService iService = new Service();
            //var service = ServiceProxy<IService>.Create(iService);
            //var result = service.DoSomething();
            Form form = FormFactory.CreateForm("FrmCategoryManager");
            form.MdiParent = this;
            form.Parent = splitContainer.Panel2;
            form.Show();
        }

        private void trvMenu_AfterSelect(object sender, TreeViewEventArgs e)
        {
            foreach (TreeNode node in trvMenu.Nodes)
            {
                node.BackColor = Color.White;
                node.ForeColor = Color.Black;
            }

            e.Node.BackColor = SystemColors.Highlight;
            e.Node.ForeColor = Color.White;

            Form form = FormFactory.CreateForm(e.Node.Tag?.ToString());
            form.MdiParent = this;
            form.Parent = splitContainer.Panel2;
            form.Show();
        }
        public static void Test()
        {
            try
            {
                SqlHelper.ExecuteNonQuery("Insert into Test(testId) values(2)");
                SqlHelper.ExecuteNonQuery("Insert 1 into Test(testId) values(1)");
            }
            catch
            {
                throw new Exception("123");
            }
        }

    }
}
